<!DOCTYPE html>
<html ng-app='test'>
  <head>
    <meta charset="utf-8">
    <title></title>
    <script src="angular.js"></script>
    <script type="text/javascript">
      let mod=angular.module('test',[]);

      mod.controller('main',function($scope,$http){
        $scope.calc=function()
        {
          $http({
            method: 'POST',
            url: '1.php',
            data:{
            a: $scope.a,
            b: $scope.b
          },
          headers: {'content-type': 'application/x-www-form-urlencoded'},
          transformRequest: function(obj){
            let arr=[];
            for(let name in obj)
            {
              arr.push(`${name}=${obj[name]}`);
            }
          //  alert(arr);
          //  alert(arr.join('&'));
            return arr.join('&');
          }
        }).then(res=>{
          //  alert(res);
            console.log(res.data);
          },
          ()=>{
            alert('error');
          }
        );
        };
      });
    </script>
  </head>
  <body ng-controller='main'>
    <input type="text" name="" value="" ng-model='a'>
    <input type="text" name="" value="" ng-model='b'>
    <input type="button" name="" value="jisuan" ng-click='calc()'>
  </body>
</html>
